package com.yuma.springaialibaba.controller;

import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class VideoSynthesisController {
    @GetMapping("/ali/video/{msg}")
    public String video(@PathVariable String msg) throws NoApiKeyException, InputRequiredException {
        VideoSynthesis vs = new VideoSynthesis();
        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .model("wan2.2-t2v-plus")
                        .prompt(msg)
                        .size("1920*1080")
                        .apiKey("sk-c2fbaa181da64b7db5c861fc31bfc5be")
                        .build();
        VideoSynthesisResult result = vs.call(param);
        return result.getOutput().getVideoUrl();
    }
}
